package jok.poker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Pokers {

	private int count;

	private List<APoker> pokers;

	public int getCount() {
		return count;
	}

	public List<APoker> getPokers() {
		return pokers;
	}

	/**
	 * 创建一副扑克
	 */
	public void createPokers() {
		this.pokers = new ArrayList<APoker>();

		for (int i = 1; i <= 4; i++) {
			for (int j = 1; j <= 13; j++) {
				this.pokers.add(new APoker(i, j));
			}
		}

		this.pokers.add(new APoker(0, 14));
		this.pokers.add(new APoker(0, 15));
		
		this.count = this.pokers.size();
	}
	
	/**
	 * 排序
	 */
	public void sortPokers(){
		Collections.sort(this.pokers);
	}
	
	/**
	 * 洗牌
	 */
	public void shufflePokers(){
		Collections.shuffle(this.pokers);		
	}
	
	/**
	 * 随机抽取一张牌
	 * @return
	 */
	public APoker getRandomAPoker(){
		Random random = new Random();
		int index = random.nextInt(this.count);
		return this.pokers.get(index);
	}
}
